package tmt.usercenter.web.repository;


import com.tmt.jpa.jpaservice.ITmtBaseRepo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import tmt.usercenter.web.domain.TmtRole;

public interface ITmtRoleRepo extends ITmtBaseRepo<TmtRole, Long> {

    TmtRole findByName(String name);

    TmtRole findById(Long id);

    TmtRole findByCode(String code);

    boolean existsByOriginSystemId(Long id);

    @Query("select t from TmtRole t where t.originSystem.id=:id and t.defaultRole=true")
    TmtRole findDefaultRoleByOriginSystemId(@Param("id") Long id);

    @Query("select t from TmtRole t where t.originSystem.clientId=:clientId and t.defaultRole=true")
    TmtRole findDefaultRoleBClientId(@Param("clientId") String clientId);
}
